package com.jiahua.utils.string;

//import org.apache.commons.codec.binary.Base64;

public class CipherUtils {

//	static Log log = LogFactory.getLog(CipherUtils.class);
//
//	private static byte[] key = { 0x74, 0x68, 0x69, 0x73, 0x49, 0x73, 0x41, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b,
//			0x65, 0x79 };// "thisIsASecretKey";
//
//	public static String encrypt(String strToEncrypt) {
//		try {
//			Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
//			final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
//			cipher.init(Cipher.ENCRYPT_MODE, secretKey);
//			final String encryptedString = Base64.encodeBase64String(cipher.doFinal(strToEncrypt.getBytes()));
//			return encryptedString;
//		} catch (Exception e) {
//			log.error("Error while encrypting", e);
//		}
//		return null;
//
//	}
//
//	public static String decrypt(String strToDecrypt) {
//
//		if (strToDecrypt == null || strToDecrypt == "") {
//			return null;
//		}
//		try {
//			Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
//			final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
//			cipher.init(Cipher.DECRYPT_MODE, secretKey);
//			final String decryptedString = new String(
//					cipher.doFinal(Base64.decodeBase64(strToDecrypt.replace(' ', '+'))));
//			return decryptedString;
//		} catch (Exception e) {
//			log.error("Error while decrypting", e);
//
//		}
//		return null;
//	}
//	
//	public static void main(String args[]) {
//		//Akmn1HPwkR/qaIKCsnJJEeltoZvKsZ0g00UqhYx3Pes
////		String abc = "Akmn1HPwkR/qaIKCsnJJEeltoZvKsZ0g00UqhYx3Pes";
////		String bb = "UuHCG6CY9SA8waMc9EDpQbGwVyuAEj6M0JVfWj5e+2c";
////		String dd = "Akmn1HPwkR/qaIKCsnJJEeltoZvKsZ0g00UqhYx3Pes";
//		
//    	long sessionTime = Long.parseLong("1391760488469");    	
//    	long nowTime = System.currentTimeMillis();
//    	
//    	long deadTime = sessionTime + 3 * 60 * 100;
//    	System.out.println("sessionTime  = " + sessionTime);
//    	System.out.println("nowTime      = " + nowTime);
//    	System.out.println("deadlineTime = " + deadTime);
//    	if ((nowTime > deadTime)) {
//    		System.out.println("invalidate");
//    	} 
//	
//	}
}